/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.utfpr.dao;

import br.com.caelum.vraptor.ioc.Component;
import br.edu.utfpr.bean.Cliente;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 *
 * @author guardezi
 */

@Component
public class DaoCliente {
    private final EntityManager em;

    public DaoCliente(EntityManager em) {
        this.em = em;
    }
    
    public void gravar(Cliente c){
        em.merge(c);
    }
    
    public List lista(){
        Query q = em.createQuery("select c from Cliente c");
        return  q.getResultList();
    }
    
    public void excluir(Long cpf){
        Cliente c =em.find(Cliente.class, cpf);
        em.remove(c);
    }
}
